Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-30583 Fix parquet column reads #17946

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

jackdelv
Copy link
Contributor

@jackdelv jackdelv commented Oct 24, 2023

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@jackdelv jackdelv changed the title HPCC-30583 Fix parquet column reads. HPCC-30583 Fix parquet column reads Oct 24, 2023
@jackdelv jackdelv requested a review from dcamper October 24, 2023 12:44
@github-actions
Copy link

@dcamper
Copy link
Contributor

dcamper commented Oct 24, 2023

@jackdelv The fact that XPATH is now supported may be worth a documentation update. I suspect that this issue -- where a Parquet file contains a field name that does not cleanly map to an ECL attribute name -- will come up quite often, like it does with XML and JSON files. It would be worth calling out to the ECL programmer that using XPATH as usual is the correct workaround.

Copy link
Contributor

@dcamper dcamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing only the README. Good verbiage describing XPATH, just need to tweak the name of "Parquet".

@@ -32,7 +32,14 @@ The Parquet Plugin offers the following main functions:

The Read function allows ECL programmers to create an ECL dataset from both regular and partitioned Parquet files. It leverages the Apache Arrow interface for Parquet to efficiently stream data from ECL to the plugin, ensuring optimized data transfer.

In order to read a parquet file it is necessary to define the record structure of the file you intend to read with the names of the fields as stored in the parquet file and the type that you wish to read them as. It is possible for a parquet file to have field names that contain characters that are incompatible with the ECL field name definition. For example, ECL field names are case insensitive causing an issue when trying to read parquet fields with uppercase letters. To read field names of this type an XPATH can be passed as seen in the following example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should capitalize 'Parquet'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@jackdelv
Copy link
Contributor Author

@dcamper I have updated the documentation to make it clearer to the user how to read a parquet file. Updated the example code to show an XPATH example.

@jackdelv jackdelv requested a review from dcamper October 25, 2023 15:52
@@ -1337,7 +1336,8 @@ void ParquetRowBuilder::nextField(const RtlFieldInfo *field)
nextFromStruct(field);
return;
}
auto column = result_rows->find(field->name);
(*array_visitor) = std::make_shared<ParquetArrayVisitor>();
auto column = result_rows->find(field->xpath ? field->xpath : field->name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not new/future/question:

for records with many fields, this linear search by field name per column into an arrow::Array could be quite expensive by the looks of it.
I assume their positions in the array are invariant between calls to nextField for a given ParquetRowBuilder instance?
And are probably also invariant from row to row?

Can you prepopulate a map before ParquetRowStream::nextRow() is called with a table from RtlFieldInfo -> to position in the arrow::Array, to avoid these find's ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean by a table from RtlFieldInfo? The result_rows object is a prepopulated map with the field name of the column and an array containing the values for that column. You are correct in that the positions are invariant from row to row and between calls to nextField.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread. I thought the code was performing a find in arrow::Array per field name.
I see now that it's a find in 'result_rows' which is an unordered_map, whose rhs is a arrow::Array.

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackdelv - looks good.

One question not directly related to the changes here.

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackdelv looks good. Please squash and I will merge.

@jackdelv
Copy link
Contributor Author

@ghalliday squashed

@ghalliday ghalliday merged commit 7b7a725 into hpcc-systems:candidate-9.4.x Nov 2, 2023
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants